/*
给定一个 N 叉树，返回其节点值的前序遍历。

例如，给定一个 3叉树 :

 



 

返回其前序遍历: [1,3,5,6,2,4]。
*/
/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
private:
    vector<int> res;
public:
    vector<int> preorder(Node* root) {
        pre_order(root);
        return res;
    }

    void pre_order(Node* root){
        if(root==NULL){
            return ;
        }
        res.push_back(root->val);
        for(auto& child:root->children){
            pre_order(child);
        }
    }

};